package academic.emailClient.model.entities;

import java.util.Date;
import java.util.UUID;

/**
 * class used to build the message
 */
public class MessageBuilder {
	
	private UUID id;
	private String to;
	private String from;
	private String cc;	
	private String subject;
	private String bodyMessage;
	private Date date;
	private int duration;
	
	/**
	 * With Id method
	 * @param id
	 * @return
	 */
	public MessageBuilder withId(UUID id){
		this.id = id;
		return this;
	}
	
	/**
	 * With to method
	 * @param id
	 * @return
	 */
	public MessageBuilder withTo(String to){
		this.to = to;	
		return this;
	}
	
	/**
	 * With from method
	 * @param id
	 * @return
	 */
	public MessageBuilder withFrom(String from){
		this.from = from;
		return this;
	}
	
	/**
	 * With cc method
	 * @param id
	 * @return
	 */
	public MessageBuilder withCc(String cc){
		this.cc = cc;
		return this;
	}
	
	/**
	 * With Id method
	 * @param id
	 * @return
	 */
	public MessageBuilder withSubject (String subject){
		this.subject = subject;
		return this;
	}
	
	/**
	 * With body method
	 * @param id
	 * @return
	 */
	public MessageBuilder withBodyMessage (String bodyMessage){
		this.bodyMessage = bodyMessage;
		return this;
	}
	
	/**
	 * With Id method
	 * @param id
	 * @return
	 */
	public MessageBuilder withDate (Date date){
		this.date = date;
		return this;
	}
	
	/**
	 * build method
	 * @param id
	 * @return
	 */
	public Message build(){
		if (this.id == null)
			return new Message(to, from, cc, subject, bodyMessage);
		return new Message(id, to,from, cc, subject, bodyMessage, date);
	}
}
